class A{//继承相同属性及方法
    //如果不想被继承可以加final,即 final class A,此时A叫密封类
    public int age=77;
    public int score;
    public String name;
    public  A(){

    }
    public void learn(){
        System.out.println("please learn before");
    }
    public void fun1(){
        System.out.println("这是父类的打印同名");
    }

    public A(int age, int score, String name) {
        this.age = age;
        this.score = score;
        this.name = name;
    }
}
class student0 extends A{
    public student0(){//编译器默认初始化该父类构造方法
        super();
    }
}
class studen1 extends A{//student1c继承A
//父类和子类有同名变量，优先访问子类的变量
    int age=10;
    public studen1(){
        //构造子类方法之前必须对父类构造方法初始化，且必须通过调用父类构造方法来初始化
        super(10,91," 张三");//先调用父类构造方法
    }
    public void fun1(){
        System.out.println("这是子类同名函数的打印");//同名函数优先访问子类的方法
    }
    public void func(){
        fun1();
    }
    public void fun0(){
        System.out.println(super.age);//通过super关键字访问父类同名变量
    }
}
class student2 extends A{//student2叫子类、派生类，A叫父类、基类、超类
    public student2(){

        super(20,90,"李四");//必须放在子类构造方法的第一行
    }

}

public class InHerit_Study {
    public static void main(String[] args) {
        studen1 stu1=new studen1();
        stu1.fun1();
    }
    public static void main0(String[] args) {
        studen1 stu1=new studen1();

    }
}
